﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dzzzr
{
	public class PropertyOrderPair : IComparable
	{
		private int _order;
		private string _name;
		public string Name
		{
			get
			{
				return _name;
			}
		}

		public PropertyOrderPair(string name, int order)
		{
			_order = order;
			_name = name;
		}

		public int CompareTo(object obj)
		{
			//
			// Sort the pair objects by ordering by order value
			// Equal values get the same rank
			//
			int otherOrder = ((PropertyOrderPair)obj)._order;
			if (otherOrder == _order)
			{
				//
				// If order not specified, sort by name
				//
				string otherName = ((PropertyOrderPair)obj)._name;
				return string.Compare(_name, otherName);
			}
			else if (otherOrder > _order)
			{
				return -1;
			}
			return 1;
		}
	}
}
